We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15136
    • 34 Posts
    Hey guys I have a chunk that contains all the stuff that goes in the <head> tag such as .js and .css files that are needed across the site. However I have 1 page, my contact page that needs additional .js files and .css files and I don’t want to put them in with the rest of the stuff that is used on the entire site because i want to limit the http requests.


    So what options do I have to stay faithful with the modx templating system? Thanks.
      2.2.4 Revolution
      • 3749
      • 24,544 Posts
      You could just use a different template for that page, or you could add a snippet to that page with something like the following (one line for each file you need injected into the <head> section):

      <?php
      $modx->regClientCSS('path/to/css/file');
      $modx->regClientStartupScript('path/to/js/file');
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 15136
        • 34 Posts
        The code you provided (after being modified for my filepaths) worked perfectly for what I needed it for. Thanks a bunch.
          2.2.4 Revolution
          • 3749
          • 24,544 Posts
          Glad it worked. Thanks for reporting back. smiley
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 33337
            • 3,975 Posts
            I use a TV [[*extraCSSJS]] and use it for page specific css and js.
              Zaigham R - MODX Professional | Skype | Email | Twitter

              Digging the interwebs for #MODX gems and bringing it to you. modx.link
              • 16610
              • 634 Posts
              Quote from: zi at Dec 02, 2010, 07:42 AM

              I use a TV [[*extraCSSJS]] and use it for page specific css and js.

              Same method here, [*codeInHead*]. Usable only by admin role users.

              It would be very useful to gather this kind of "good practise" tips in one place. With MODx you can always do the same thing in many ways but often one way is more efficient than others.
                Mikko Lammi, Owner at Maagit
                • 26016
                • 561 Posts
                Quote from: BobRay at Dec 02, 2010, 01:16 AM

                Glad it worked. Thanks for reporting back. smiley

                If MODx ever goes IPO, I vote for Bob to get the first couple million!

                Dave
                  MODx and Wordpress development
                  Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4