ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

internal or external CSS and .js - which is optimal to use?

July 28, 2012 7:15pm

Subscribe [3]
  • #1 / Jul 28, 2012 7:15pm

    Enviromed

    375 posts

    In the user manual under linking to stylesheets it is said:
    Keeping your stylesheet in EE adds the bonus of automatic css cache busting, for example: style.v.1337589627

    Christopher Imrie at moresoda, has written that for example if you have 2 css and 3 js templates it adds enormous overhead because EE parses the template 6 times. 

    What is best practices?  Thanks in advance for excellent support.

     

  • #2 / Jul 28, 2012 8:15pm

    R.K.Foster

    138 posts

    I found that with some sites the CSS was not being read properly because of browser caching of the stylesheet. For better or worse I use the old fashioned server file system for both javascripts and css. The only time I put javascripts in Exp Eng is when I need to generate custom content inside the javascript using an Exp Eng channel tag for example.

    In addition, images used in a CSS style sheet will always be found if you use an ‘images’ directory inside the ‘css’ directory and use relative URL’s in the CSS. Putting CSS in Exp Eng, and not taking the full path into account, can lead to images not found or broken CSS on your web page. In other words, if you use an embed or snippet to include the links to your style sheet, and it is a relative path, then things may break if you didn’t work out the paths correctly.

    It just became easier to me to just use

    {site_url}css/images/someimage.png
    {site_url}css/somestyle.css

    Wherever I need it in a template.

    But there may be other technical reasons why the ‘stylesheet’ tag is useful that I’m not aware of.

    - Bob.

  • #3 / Jul 28, 2012 8:25pm

    Enviromed

    375 posts

    Thanks so much.  We’ll continue to do the code as you have it - which is working fine. . .but needed confirmation on whether to change.

  • #4 / Jul 30, 2012 12:52pm

    Shane Eckert

    7174 posts

    Hey Enviromed,

    I am glad to see that Bob was able to help!

    If you need anything else, please just let me know by opening a new thread.

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases