Hi,

Just working on my first Drupal Theme. Im working from a Zen base theme. I just had a look at the header output and it seems so bloated. Are all these javascript files necessary? Is there any way to find out what each one is doing exactly to determine if it can be removed?

<script type="text/javascript" src="http://localhost/misc/jquery.js?v=1.4.4"></script>
<script type="text/javascript" src="http://localhost/misc/jquery.once.js?v=1.2"></script>
<script type="text/javascript" src="http://localhost/misc/drupal.js?m2jbzq"></script>
<script type="text/javascript" src="http://localhost/misc/ui/jquery.ui.core.min.js?v=1.8.7"></script>
<script type="text/javascript" src="http://localhost/misc/ui/jquery.ui.widget.min.js?v=1.8.7"></script>
<script type="text/javascript" src="http://localhost/misc/jquery.cookie.js?v=1.0"></script>
<script type="text/javascript" src="http://localhost/misc/jquery.form.js?v=2.52"></script>
<script type="text/javascript" src="http://localhost/misc/ui/jquery.ui.mouse.min.js?v=1.8.7"></script>
<script type="text/javascript" src="http://localhost/misc/ui/jquery.ui.draggable.min.js?v=1.8.7"></script>
<script type="text/javascript" src="http://localhost/misc/ui/jquery.ui.resizable.min.js?v=1.8.7"></script>
<script type="text/javascript" src="http://localhost/misc/jquery.ba-bbq.js?v=1.2.1"></script>
<script type="text/javascript" src="http://localhost/modules/overlay/overlay-parent.js?v=1.0"></script>
<script type="text/javascript" src="http://localhost/modules/contextual/contextual.js?v=1.0"></script>
<script type="text/javascript" src="http://localhost/misc/ajax.js?v=7.12"></script>
<script type="text/javascript" src="http://localhost/sites/all/modules/admin_menu/admin_devel/admin_devel.js?m2jbzq"></script>
<script type="text/javascript" src="http://localhost/misc/progress.js?v=7.12"></script>
<script type="text/javascript" src="http://localhost/sites/all/modules/devel_themer/devel_themer.js?m2jbzq"></script>
<script type="text/javascript" src="http://localhost/sites/all/modules/devel/krumo/krumo.js?m2jbzq"></script>
<script type="text/javascript" defer="defer" src="http://localhost/sites/all/modules/admin_menu/admin_menu.js?m2jbzq"></script>
<script type="text/javascript" defer="defer" src="http://localhost/sites/all/modules/admin_menu/admin_menu_toolbar/admin_menu_toolbar.js?m2jbzq"></script>

Thanks

Comments

betarobot’s picture

In very brief: you need them all as you enabled this or that module and you expect some functionality coming along with them. You can easily check where *this* script belongs by looking at uri. Say http://localhost/sites/all/modules/admin_menu/admin_menu.js?m2jbzq is clearly coming from admin menu module, etc.

Majority of js in your example comes exactly for development situation and will not be loaded for visitors. It is also advised that you'd turn on JS and CSS aggregation for production site (configuration -> performance), so all of them would be compacted just in a couple of js files.

Banana Man’s picture

Ahh, thanks. Yes, i have a fair few theme designing modules installed. Didn't know about the CSS aggregation either!

ahimsauzi’s picture

Hi Andrey,

Any idea how to remove an inline javascript added to the head by a module? I uninstalled the module empty cache but still see that inline javascript. Is there a database table inline scripts are stored in?

Thanks,
Uzi

betarobot’s picture

Hey Uzi,

You can try manually clear/truncate any cache* table in db. It's safe enough.

Also you may just unset js for particular module even if it is installed via template.php preprocess. Some tips here: http://drupal.stackexchange.com/a/5107/4161