Results 1 to 8 of 8
  1. #1

    Default Exclude css and javascript from home page?

    Is there a way to exclude universal css and javascript files from just my home page?
    I want my home page to load as quickly as possible and don't need much css or any javascript at all so I'd like to prevent those files loading but by default, Zen Cart picks up anything that begins with style or jscript for every page.
    Is there a way I can be more selective about when they load?

    Thanks for your help!

  2. #2
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Exclude css and javascript from home page

    Zen Cart picks them up in your template's common/html_header.php file (or the base file in template_default if your template doesn't have it's own).

    You could wrap this in a php if statement using the $this_is_home_page variable to create a specific and different loading approach for the home page.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  3. #3

    Default Re: Exclude css and javascript from home page

    Thanks Kuroi!
    I'll give that a try, sounds like exactly what I'm looking for!

  4. #4
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Exclude css and javascript from home page

    Quote Originally Posted by damiantaylor View Post
    I want my home page to load as quickly as possible and don't need much css or any javascript at all so I'd like to prevent those files loading but by default, Zen Cart picks up anything that begins with style or jscript for every page.
    Is there a way I can be more selective about when they load?
    I recommend being more selective *in general*.
    Last I recall from your posts I think you had something like 8 different stylesheets loading? That stems from having numerous addons in action. Many people have many excess things set up on their site that they fail to clean up when they're done experimenting. Maybe some of yours are overkill?

    Also, if certain stylesheets only apply to certain pages, make sure you name them accordingly so they only load where appropriate.

    And, when it comes to javascript too, ZC only loads the generic ones on all pages. If you have them named appropriately to show on only certain pages, it will respect that.

    You really shouldn't need to do any hacking of core code to limit what it normally does smartly and automatically.

    Reading:
    http://www.zen-cart.com/wiki/index.p..._-_Stylesheets
    http://www.zen-cart.com/wiki/index.p...s_-_Javascript
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Exclude css and javascript from home page

    Am I correct in interpreting your post today as an indication that enabling caching of stylesheets and js (in your post a few days ago) was moot and didn't actually deliver the results you were praising?
    Your post today certainly appears to contradict the other.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  6. #6

    Default Re: Exclude css and javascript from home page?

    Hi DrByte,
    If you're talking about the combining stylesheets post, it did deliver gains, I'm just after more!

    My web host has recently switched mySQL query caching on and done some other tuning work for me but my home page can still take 4 or 5 seconds to load first time in which I want to reduce.
    Once inside the site, each page only takes 1 or 2 seconds to load presumably because of caching?

    I'm new to all this (the php I've learned is thanks to Zen Cart and I've only been using Zen Cart for a few months) but wanted to share the css/js combination technique I'd learned in case it was useful to anyone else.
    I've been given loads of help by kind people such as yourself on here so just wanted to give something back.

    You're right in that I do have lots of individual universal stylesheets because of the mods I've added.
    My idea as far as the home page goes is to only load what I need.
    If it doesn't reduce the load time significantly, I'll put it back as it was.
    I'm kind of grabbing at straws in my attempt to make my home page load as quickly as possible!

  7. #7
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: Exclude css and javascript from home page?

    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8

    Default Re: Exclude css and javascript from home page?

    Yeah, done all that.
    I've done as you suggested and started looking at moving my universal js and css to page specific if I can.
    Hopefully I'll be able to do something there :)

 

 

Similar Threads

  1. CSS Exclude for home page?
    By completespray in forum General Questions
    Replies: 4
    Last Post: 1 Oct 2011, 10:45 PM
  2. Customizing home page with javascript
    By brokenbird in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 28 Aug 2011, 04:52 AM
  3. JavaScript and CSS issues
    By krastley in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 13 Apr 2011, 09:03 PM
  4. Exclude sideboxes from home page only?
    By Vood in forum General Questions
    Replies: 13
    Last Post: 14 Feb 2008, 11:08 PM
  5. customizing and removing product from home page
    By katandmouse in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 6 Aug 2007, 06:45 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