BWP Minify Breaking Infinite Scrolling
-
Hello,
I’ve found when I enable js minify through the plugin it breaks my working infinite scrolling causing it to throw the following error:
ReferenceError: Can’t find variable: infinite_scroll
Looking into the html I noticed that the standard <script> tag which infinite scroll uses to initialize was now above the minified <script> inclusion breaking it’s hierarchy.Rendered HTML (Note minified scripts are now after the infinite scroll.
<script type="text/javascript"> // Because the <code>wp_localize_script</code> method makes everything a string infinite_scroll = jQuery.parseJSON(infinite_scroll); jQuery( infinite_scroll.contentSelector ).infinitescroll( infinite_scroll, function(newElements, data, url) { eval(infinite_scroll.callback); }); </script> <script type='text/javascript'> /* <![CDATA[ */ var infinite_scroll = "{\"loading\":{\"msgText\":\"<em>Loading...<\\\/em>\",\"finishedMsg\":\"<em>No additional posts.<\\\/em>\",\"img\":\"http:\\\/\\\/myvancity.ca\\\/wp-content\\\/plugins\\\/infinite-scroll\\\/img\\\/ajax-loader.gif\"},\"nextSelector\":\".page_nav_wrap .post_nav a.next\",\"navSelector\":\".page_nav_wrap\",\"itemSelector\":\".post\",\"contentSelector\":\"#content\",\"debug\":false,\"behavior\":\"\",\"callback\":\";(function($) {\\r\\n var $w = $(window),\\r\\n th = 200,\\r\\n attrib = \\\"data-src\\\",\\r\\n images = $('img[data-src]'),\\r\\n inview;\\r\\n\\r\\n images.bind('scrollin', {}, function() {\\r\\n load_image(this);\\r\\n });\\r\\n $w.scroll(unveil);\\r\\n $w.resize(unveil);\\r\\n unveil();\\r\\n\\r\\n function unveil() {\\r\\n inview = images.filter(function() {\\r\\n var $e = $(this),\\r\\n wt = $w.scrollTop(),\\r\\n wb = wt + $w.height(),\\r\\n et = $e.offset().top,\\r\\n eb = et + $e.height();\\r\\n return eb >= wt - th && et <= wb + th;\\r\\n });\\r\\n images = images.not(inview.trigger('scrollin'));\\r\\n }\\r\\n\\r\\n function load_image(img) {\\r\\n var $img = jQuery(img),\\r\\n src = $img.attr(attrib);\\r\\n $img.unbind('scrollin').hide().removeAttr(attrib);\\r\\n img.src = src;\\r\\n $img.fadeIn();\\r\\n }\\r\\n return this;\\r\\n})(jQuery);\"}"; /* ]]> */ </script> <script type='text/javascript' src='https://myvancity.ca/wp-content/plugins/bwp-minify/min/?f=wp-content/plugins/wp-gallery-custom-links/wp-gallery-custom-links.js,wp-content/plugins/infinite-scroll/js/front-end/jquery.infinitescroll.js,wp-content/plugins/unveil-lazy-load/js/jquery.optimum-lazy-load.min.js,wp-content/themes/duena/js/navigation.js,wp-content/themes/duena/js/skip-link-focus-fix.js,wp-content/themes/duena/js/superfish.js,wp-content/themes/duena/js/jquery.mobilemenu.js,wp-content/themes/duena/js/sfmenu-touch.js,wp-content/themes/duena/js/add2home.js,wp-content/themes/duena/js/jquery.flexslider.js,wp-content/themes/duena/js/jquery.magnific-popup.js,wp-content/themes/duena/js/bootstrap.js,wp-content/themes/duena/js/custom.js&ver=1390165509'></script>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘BWP Minify Breaking Infinite Scrolling’ is closed to new replies.