Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2015
    Posts
    206
    Plugin Contributions
    0

    Default Css/js loader defer Question

    I am using the css/js Loader plugin.
    https://www.zen-cart.com/downloads.php?do=file&id=1774

    I have some issues with performance on my website.
    A suggestion was to async the css and defer the JavaScript.

    I was wondering if it was possible to aysnc the css using the css/ js loader?

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    8,941
    Plugin Contributions
    71

    Default Re: Css/js loader defer Question

    I'm pretty sure (read not absolutely sure) that the current version from Numinix's website supports javascript deferrals.

  3. #3
    Join Date
    Jan 2015
    Posts
    206
    Plugin Contributions
    0

    Default Re: Css/js loader defer Question

    Quote Originally Posted by lat9 View Post
    I'm pretty sure (read not absolutely sure) that the current version from Numinix's website supports javascript deferrals.
    yes it does support the javascript. But its the css i am having trouble with

  4. #4
    Join Date
    Feb 2009
    Location
    UK
    Posts
    654
    Plugin Contributions
    0

    Default Re: Css/js loader defer Question

    Following your original post I thought I would take a look at this - as currently I only defer the jscript.

    in templates/MY_TEMPLATE/auto_loaders/loader_css.php (create it if it doesn't exist), add this (you can also wrap a conditional statement around this as mentioned in the plugins Readme)

    Code:
    <?php
      $loaders[] = array('conditions'    => array('pages' => array ('*')),
                       'css_files' => array(
    		'defer/something.css' => array(
          'order' => 1,
          'defer' => true
        )
    		)
                        );
    ?>
    and, for example, add something.css to templates/MY_TEMPLATE/css/defer/

    then at/near the bottom of your page code you should see the deferred css as:

    Code:
    <script type="text/javascript" async>
    						var elm = document.createElement("link");
    						elm.rel = "stylesheet";
    						elm.type = "text/css";
    						elm.href = "min/?f=/includes/templates/MY_TEMPLATE/css/defer/something.css&1570615485";
    						
    						var links = document.getElementsByTagName("link")[0];
    						links.parentNode.appendChild(elm);
    					</script>
    There will also be a noscript entry near the top of the page:

    Code:
    <noscript><link rel="stylesheet" type="text/css" href="min/?f=/includes/templates/MY_TEMPLATE/css/defer/something.css&1570615485" /></noscript>
    Pretty sure this works.
    Simon

  5. #5
    Join Date
    Jan 2015
    Posts
    206
    Plugin Contributions
    0

    Default Re: Css/js loader defer Question

    That seems to do the trick... What if I wanted to add multiple css files. How would I change the code.

    How come you don't defer your css?

  6. #6
    Join Date
    Feb 2009
    Location
    UK
    Posts
    654
    Plugin Contributions
    0

    Default Re: Css/js loader defer Question

    Tried a couple of things to defer multiple css files - none seem to work, so I don't know. Maybe someone else can chime in.

    I just never got round to deferring css, Google no longer complains or asks me to defer css - I may look at it in the future but am happy with the performance of my site at the moment.
    Simon

 

 

Similar Threads

  1. v153 CSS JS Loader [Support Thread]
    By lat9 in forum All Other Contributions/Addons
    Replies: 155
    Last Post: 10 Dec 2018, 09:28 AM
  2. css javascript loader addon problems
    By tony_sar in forum All Other Contributions/Addons
    Replies: 110
    Last Post: 25 Aug 2014, 11:05 AM
  3. v151 CSS/JS Loader installation question
    By McLovin in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 12 Feb 2014, 06:28 PM
  4. css/js loader !!
    By Miff in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 28 Nov 2011, 01:19 PM
  5. CJ Loader (CSS/Javascript Loader) plugin function is not loaded by zen cart?
    By tripflex in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 11 Jul 2011, 03:55 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR