0

I'm setting up Omega 4 using SASS / Compass for the first time, I have:

  • Linux VM running apache and guard
  • Windows machine for code editing and browser

Whatever I do I cannot find livereload.js in the page source.

  • Guard is running fine
  • I have cleared the cache several times
  • I can view the script at ip.ad.dr.ess:35729/livereload.js and at my_site.com:35729/livereload.js in my browser
  • I've tried changing the settings at admin/appearance/settings/my_theme to various different things but I don't think that makes a difference if the script is not included in page source

Any gems of wisdom would be greatly appreciated.

  • if you're comfortable overriding - have you tried manually including it in html.tpl.php? It doesn't answer the UI or behind the scenes of why it isn't working, but could be a stop-gap in meantime. – Geoff Nov 24 '14 at 0:20
  • That did the trick thanks Geoff, which makes me feel very sheepish. Please add this as an answer so you can be rewarded if nobody has a fix for the underlying problem. – Darvanen Nov 24 '14 at 0:58
  • Are you using this as part of the Omega 4 theme (ie, from the devel tab on theme settings)? If so, did you run the makefile when you made the subtheme? – mpdonadio Nov 24 '14 at 16:53
  • Thanks MPD, yes I did run the makefile and yes I'm running livereload as provided by Omega4 (in the devel tab). – Darvanen Nov 24 '14 at 22:30
1
+100

From what it seems, your website is probably looking for the file in the wrong location. Or it may be overriden by another module. Where and how is the file specified in your theme?

Meanwhile, here's what I would do to track down the issue.

Enable Error Logging

This way you can see the errors happening in the backend, such as Drupal attempting to fetch a file from a wrong directory.

  1. Make sure the Database logging module is enabled, it manages Drupal related errors.
  2. Check the log messages for errors (/admin/reports/dblog).
  3. If you still do not see an error, you might need to login as an admin. If you're not an admin, adjust permissions.
  4. Enable PHP display_errors and log_errors to log errors on the PHP side. You can then check the log file to see which error is being thrown. You may need to create a phpinfo.php file to see if the error log is enabled and the location of the error log.

Disable Caching

Sometimes the way caching works, may interfere with your setup. It also helps you see every *.js file that is called.

  1. Make sure you do not have any other 3rd party caching modules enabled, e.g. Boost.
  2. Make sure you have all caching disabled, including Aggregate JavaScript files. (Not CSS Aggregate) and Cache pages for anonymous users (/admin/config/development/performance).

Try Alternative Solutions

This doesn't necessarily fix the issue, but may provide a solution for the time being.

1) Attach javascript in template.php

<?php
  function MYTHEME_preprocess_html(&$variables) {
    drupal_add_js(drupal_get_path('theme', 'MYTHEME') .'/script.js', 'file');
  }

2) Attach javascript in page.tpl.php

<?php
drupal_add_js(path_to_theme().'/js/script.js');

3) Attach javascript in html.tpl.php.

I would try to avoid this option, since it's the least Drupal way, and you might not be able to use drupal_add_js(). But if you have to, you can specify the script, by putting the following between your <head></head> tags.

<script type="text/javascript" src="path/to/file/scripts.js"></script>

Check Module by Module

As a last option, I would make a new install of the website and see if everything works there. If it doesn't, it's more likely that there's a bug in the few modules that you have installed. If everything does work with the new installation, then the problem is in your website; so duplicate the original site and uninstall modules one by one to see what's causing the issue.

There are many other ways you can crack down the problem, by installing a Devel Module and passing dpm($variable) throughout files.

Hope it helps!

| improve this answer | |
  • 1
    Javascript aggregation! Halleluja! What an idiot I was. Thank you for this most excellent answer. Hopefully it becomes a resource for others facing the same problem. – Darvanen Nov 26 '14 at 5:28
  • Sometimes the answer is as simple as that! :) – timofey.com Nov 26 '14 at 5:37
1

Livereload will only be added to the page if the Drupal instance can reach out to the livereload.js specified. Note that loading it in your browser (remotely from the server) is different than Drupal loading it from the machine. Drupal is running under Apache as a process on the machine. What it sounds like is Drupal/Apache/PHP cannot access the settings you have in Omega.

If you are familiar with Linux command line. Log into the machine and attempt to load the livereload.js file using wget from the machine using the exact URL you are using in Omega. If you do not get a return, you have found the problem.

| improve this answer | |
  • Thanks very much Brady, I just tried this and it worked fine, I got a copy of the .js file in my home directory. I also get an error from Drupal when I turn guard off saying it can't find livereload.js that disappears again when guard resumes. – Darvanen Nov 24 '14 at 22:33
  • I have looked at the code that loads this JS. If the load is failing you should be getting a warning messages on your site. I just did a test on my local dev environment and I get an error on the site since it cannot load the JS file. To see the error you must have the role "administer site configuration". Also there is a flood control on the warning of 3600 seconds. – Brady Nov 25 '14 at 17:17
  • Also make sure you have CSS aggregation turned off. Doesn't work with it on. – Brady Nov 25 '14 at 17:19
  • Ah! That would explain why the warning goes away... this now makes a lot more sense, and yeah I'm not using CSS aggregation, but thanks for the tip. – Darvanen Nov 25 '14 at 23:34
0

Check if the protocol of the website as you view it and the url that points to livereload.js are the same. They should be both the same either HTTPS or HTTP.

| improve this answer | |
  • Thanks W.M. unfortunately this does not answer my question. I can view the script fine at its URL, but the script reference is not being added to any page. – Darvanen Nov 23 '14 at 23:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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