We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30277
    • 75 Posts
    Hi

    I was normally have all my css under assets/templates/mytheme/xxx.css or js files under assets/js/
    I read an article at modx wiki about moving this files to document tree and i thought its cool but cant understand much which is better and why shuold i prefer .

    It will be good if power modx users, stuff share how to use them, put their inputs pros/cons about it smiley thanks
      • 25663 MODX Staff
      • 12,272 Posts
      Using CSS as a document allows you to have logic in your PHP and to dynamically change it with snippets.
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 30277
        • 75 Posts
        Quote from: rthrash at Apr 04, 2007, 11:43 AM

        Using CSS as a document allows you to have logic in your PHP and to dynamically change it with snippets.

        Thanks rthrash, is it also good if we use js files like that ?
          • 22303 MODX Staff
          • 10,725 Posts
          You can use this technique to generate any kind of content dynamically. I’ve used it to generate various XML formats, including RSS, GeoRSS, and several proprietary formats for custom applications (Flash remoting, AJAX, etc.), JSON responses for AJAX requests, traditional javascript files, and even dynamic graphs generated as .gif’s. Any content you can produce with a PHP script is fair game.
            • 30277
            • 75 Posts
            Thank you OpenGeek ill go reset my test site with this updates smiley
              • 4626
              • 57 Posts
              Wouldn’t it speed-wise be better if css and js-files are static documents instead of being parsed by the modx-engine?
              I would think that it’s only when you need to have the css and js to dynamically adapt to your content that having these in the database/document tree would be beneficial.
                • 25663 MODX Staff
                • 12,272 Posts
                It would indeed likely be faster to have js/css as static regular old files on the filesystem. But if you turn on caching, then that kinda-sorta happens, though with a tiny bit more overhead. You could then cache the documents but call the always changeable bits uncached.
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me