Image lazy loading using JS

Image lazy loading using JS, improve your website speed. Lazy loading images JavaScript Background-image lazy load Lazy load images jQuery Piece of html code // jquery librabray <script src=”https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js”></script> <img class=”lazy” data-src=”http://example.com/image.png” /> <img class=”lazy” data-src=”http://example.com/image.png” /> <img class=”lazy” data-src=”http://example.com/image.png” /> <img class=”lazy” data-src=”http://example.com/image.png” /> jQuery code setTimeout(function() { lazyLoadImages( $(‘.lazy’) ); }, 100); var […]

Detect device in jQuery

Sometime we need to detect device in jQuery to identify the screen, To add some extra or different logic according to the requirement. 5 ways to detect the mobile Devices in jQuery Solution 1:- Using navigator userAgent. if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) { // mobile device code } Solution 2:- Using window matchMedia method $(function() { […]

Add Product With Custom Options To Cart Graphql in Magento 2

Add product to cart GraphQL Magento 2 Add product to cart GraphQL Magento 2 or Add Simple Product With Custom Options To Cart in Magento2 Method Post AUTHORIZATION Bearer Token BODY graphql mutation { addSimpleProductsToCart( input: { cart_id: “ctxNWM4yYu4udYCUm8TSeXZOdv7VXv72” cart_items: [ { data: { quantity: 1 sku: “test” } customizable_options: { id: 16, value_string: “28” […]

Back To Top