Hello,

Thanks for this fantastic module!! Is it possible to enable loadCSS only or certain pages? I do not want to use the "Inline CSS/JS on specific pages" because this will not load my actual styles.

I actually want to use the "Deferred CSS Execution: Use JS to load CSS" but only on specific pages because then I can actually combine that with critical-css that I already have in place.

Is there a way to achieve this?

Best regards
Joao Garin

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joaogarin created an issue. See original summary.

joaogarin’s picture

I am attaching a patch that ads this functionality.

Its quite simple and much like the already existing admin paths setting on the 7.x version. works as following :

1 ) In the settings page the user can provide the pages for enabling CSS deferring on specific pages. One per line in a textarea.
2 ) In the module file, if in the previous setting something was added (page paths) and the page does matches any of those pages, it just exists the page (return early).

if the user does not specify anything in this setting field it is just ignored and works as it already does.

The motivation behind this is that loadCSS requires you do something to get the above the fold CSS on the page (inline typically using something like criticalCSS). This is a task that is not so easily accomplished and sometimes it makes sense this is done for the most common entry points of the site such as landing pages, frontpage etc. But not for all pages of the site.

So this way you can have CSS defer on these pages, and the remaining pages just work as normal. This reduces the risk of using this setting since you can apply it on only one or two pages and actually see how they perform and gradually move to more pages.

Best regards
Joao Garin

joaogarin’s picture

Changing status of the issue.

joaogarin’s picture

Status: Active » Needs review
mikeytown2’s picture

Here's a modified version of your patch

  • mikeytown2 committed c7b6147 on 7.x-2.x
    Issue #2671148 by joaogarin, mikeytown2: Enable loadCSS only on specific...
mikeytown2’s picture

Status: Needs review » Fixed

#5 has been committed.

joaogarin’s picture

Awesome;) tks and congrats on a great module.

pdesai’s picture

Noticed a bug in advagg_mod.module:718 - missing "/src/" in the URL path: http://cdn.rawgit.com/filamentgroup/loadCSS/master/src/loadCSS.js

mikeytown2’s picture

@pdesai
The latest dev has that fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.