Skip to main content
16 events
when toggle format what by license comment
Oct 21, 2011 at 15:10 history bounty ended Matt V.
Oct 20, 2011 at 20:05 vote accept Matt V.
Oct 20, 2011 at 8:16 comment added Andy @MPD Even if the server's configured correctly to allow caching client-side, you're still requiring Drupal to call (yet another?) hook init (and drupal_add_js) on every single full bootstrap (imagecache, node views of the wrong type, Views, taxonomy pages, admin pages, 404s, etc.). At the very least it would make more sense to just add it on hook_nodeapi view while checking the content type, no?
Oct 20, 2011 at 2:00 comment added mpdonadio If you do the hook_init() thing with the library, it will be on every page, but the browser will cache it. First access to site will be slightly longer, but subsequent accesses will be fine. Net result is pages with charts will be a little faster.
Oct 18, 2011 at 12:07 history edited Andy CC BY-SA 3.0
added 33 characters in body
Oct 18, 2011 at 11:14 comment added Andy @Matt V. I've updated my answer, but as far as I know you either have to create a table yourself, or leverage a module that does that for you (eg. taxonomy) if you want to use the flag approach.
Oct 18, 2011 at 11:11 history edited Andy CC BY-SA 3.0
added 157 characters in body
Oct 17, 2011 at 21:26 comment added Matt V. @Andy (or DeeZone)... How would you go about adding the "flag" to the node inside hook_nodeapi? I'd like to avoid adding a table just to track what nodes to add the JS to, but I'm not seeing a way around that. As it stands, I'm searching for [highcharts]<code>[/highcharts] inside the filter and then wrapping the <code> portion, as needed. I'm working in Drupal 6, by the way. Thanks again!
Oct 13, 2011 at 21:22 comment added Andy @DeeZone Although the hook's not run on cached pages, that doesn't matter as the cache includes the HTML for including the CSS/JS file. It would be important if for example you had a function that updated the database every page view. I didn't realise you could add CSS/JS files in the .info file in D7, thanks for the info.
Oct 13, 2011 at 20:36 comment added DeeZone See the doc page for hook_init - api.drupal.org/api/drupal/modules--system--system.api.php/… The documentation states: "To add CSS or JS that should be present on all pages, modules should not implement this hook, but declare these files in their .info file." The "funkiness" is a result of "This hook is not run on cached pages."
Oct 13, 2011 at 16:25 comment added Andy @DeeZone - I'm not sure the results should be particularly funky, just not such a good idea from a perf perspective...
Oct 13, 2011 at 16:23 comment added Andy @Matt V. updated answer.
Oct 13, 2011 at 16:22 history edited Andy CC BY-SA 3.0
added 367 characters in body
Oct 13, 2011 at 14:41 comment added Matt V. Can either of you elaborate on why to avoid hook_init? I've noticed several contrib modules that add Javascript that way. In any case, thanks for the feedback!
Oct 13, 2011 at 13:04 comment added DeeZone Agreed, hook_init() is way too early in the bootstrap process and can result in some really funky results.
Oct 13, 2011 at 12:06 history answered Andy CC BY-SA 3.0