3

Possible Duplicate:
Remove jQuery and find out what is asking it to be included

I'm building a simple site that is focussed on performance and must run well on mobile and other low-power devices. I want to avoid jQuery if I can, and want to know if it's even possible or whether it's simply a compromise I'll have to live with. I don't want to start building with jQuery removed and have to carefully engineer things to avoid it, only to find I'll need it later, thus wasting effort better spent elsewhere.

If it can be removed, are there any gotachas? Any modules to avoid? Anything else to bear in mind?

Another thought: Can it be restricted to certain pages only, where the interaction it provides is required?

UPDATE

There is a similar question that also touches on the issue of jQuery dependency, but where that one broadly asks about dependency tracking and CSS files and theming, this one is focussed on the feasibility of removal of jQuery in Drupal and its performance implications. The accepted answer here is substantially different from the one there, as is the theme of the discussion here. Therefore I'd argue that this is not a duplicate and offers value to the community.

8
  • 2
    Revise your strategy, think your making something out of nothing. Its part of the framework, not a massive part though.
    – Alex Gill
    Jan 25, 2013 at 9:17
  • 1
    @AlexGill with the greatest of respect and goodwill, front-end performance is not "nothing" - it's all part of the UX. See j.mp/10HXxrq and j.mp/YrTtQv for example. When you say it's "not a massive part" of the framework, that's pretty vague (because the whole framework isn't sent down the pipe on every request). I just want to know if it's possible to run Drupal 7 without jQuery. If not, then that's a valid answer which I'll accept if someone wants to post it as such. If it is possible, then that's a good answer too. Either way, there's work to be done. :) Jan 25, 2013 at 12:05
  • @Chapabu I saw that other question before posting mine and thought it was substantially different. Jan 25, 2013 at 12:09
  • I'll answer the question, but at it's core both questions are the same.
    – Chapabu
    Jan 25, 2013 at 12:13
  • 1
    @Chapabu Yeah, they're similar, granted, but that other one asks about dependency tracking and CSS files and theming and Drupal in general and is much less focussed than this one. This one is just about the question of the jQuery dependency. Jan 25, 2013 at 12:26

1 Answer 1

8

jQuery is part of Drupal core - and because of this, you can't tell WHAT contrib modules are going to be using it. Well, you can, but it'd involve checking any included scripts of any module. Also, you wouldn't remove poll.module or blog.module just for server side performance if you're not using them - I would suggest the same applies to jQuery.

I don't think removing jQuery is an option at all realistically, it's not worth the hassle of even trying.

The following, however, are MUCH better options.

For starters, get your hands on the jQuery Update module if you're not using it already. One of the best things you could do to improve jQuery performance is use the most up to date version of the library possible.

Next, try Boost:.

Boost provides static page caching for Drupal enabling a very significant performance and scalability boost for sites that receive mostly anonymous traffic.

or Varnish if you are on a dedicated hosting plan and have the resources to set it up (Drupal module here).

Serving static HTML pages will take substantially less time, than serving a full dynamic page.

Lastly, if it's a REALLY simple site, evaluate whether or not you even NEED Drupal?

Could you perhaps use a Drupal back-end to manage your content and combine it with the Services module to supply your content to a more performance focused site with a lightweight framework such as Laravel? I've run into situations before where I've used Drupal because "IT'S WHAT I KNOW DAMMIT", where I could realistically have used a much lighter framework and removed a lot of overhead.

EDIT

I forgot to mention the tag. Check out other questions tagged with and there will be a plethora of people who might have similar front-end performance issues/ideas!

3
  • Fantastic answer, thanks. I'm perfectly happy to accept the jQuery overhead for the gains in developer productivity Drupal gives me. But it's important to know ahead of time what is an isn't worth optimising for. Clearly, dropping jQuery is ill-advised. Thanks for saving me a bunch of headaches. Cheers. :) FWIW I am looking at using Boost and maybe CloudFlare's full-page HTML caching + CDN. Jan 25, 2013 at 12:42
  • Boost caches the pages into HTML anyway, so I'm not sure how the CloudFlare HTML caching would help -that said, I'm only going on what it's called, so it might be super useful! I forgot to mention CDN, but you're right! They are a good way of reducing overhead :) If there's nothing else you need then don't forget to accept the answer to close the question off :) Best of luck with your project!
    – Chapabu
    Jan 25, 2013 at 12:48
  • 1
    The benefit of CloudFlare would be in use of its worldwide CDN to deliver the HTML - cloudflare.com/network-map. I could possibly do away with Boost if that on its own worked well enough. Just exploring options at the moment. BTW, the site is simple on the surface, but requires CMS features for client editing, and i18n, and will be accessed in numerous connection-poor, device-poor countries. Jan 25, 2013 at 12:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.