Answers.Body: <p>Finally located the source of the problem. Every page on the site included a widget in the footer using an HTML snippet for a CiviCRM sign-up form. The HTML snippet, despite being the one generated by the profile, was incorrect, and included a reference to an admin URL for a script, which wouldn't be accessible to non-logged in site visitors. Removing it resolved the issue.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-01T09:08:21.770Z
Answers.Text: Just to update further on this, the default HTML snippet for the profile  includes the line "var CRM = {"config":{"isFrontend":false}};" which to my mind looks incorrect. I would guess that this needs to set to 'true' for any public facing snippet?.  Also, at the end of a list of Javascript files I see the following: "<script type="text/javascript" src="/wp-admin/admin.php?page=CiviCRM&amp;q=civicrm/ajax/l10n-js/en_GB&amp;r=Lg7uq">" which makes me think that the snippet won't necessarily work for a non-logged in user, and looks to be the cause of my initial JS error noted in the question.
Answers.UserDisplayName: Graham
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-01T00:54:14.847Z
Answers.LastActivityDate: 2015-09-01T00:54:14.847Z
Answers.UserDisplayName: Graham
Answers.Body: <p>Generically: You have a Javascript error, so I would definitely consult the <a href="https://forum.civicrm.org/index.php?topic=35850.0" rel="nofollow noreferrer">Troubleshoot Javascript errors</a> post which describes additional steps to try.</p>
  
  <p>That said - I know what your problem is, and would like to give a step-by-step of how I worked it out.</p>
  
  <p>In your Javascript console (press F12 in your browser, then "Console" tab) you'll see a bunch of errors - but the first starts with "SyntaxError".
  A syntax error in JS will generally disable all the following JS on the page, which will lead to other JS not loading.  So ignore everything after the SyntaxError, that will get fixed when you find the syntax error.</p>
  
  <p>Assuming your error is:</p>
  
  <pre><code>SyntaxError: expected expression, got '&lt;'[Learn More] en_US:1
  ...(more errors below)
  </code></pre>
  
  <p>I can see the problem is on line 1 of the <code>en_US</code> file.</p>
  
  <p>So I open my browser's developer tools (F12).  Then I go to the "Network" tab, filter by JS, and reload the page.  I look for the en_US file. I right-click and select "Open in New Tab" (see screenshot below).</p>
  
  <p>What you SHOULD see is a JavaScript file that tells CiviCRM how to load the correct translations for certain fields.  What YOU will see is a first line with <code>&lt;[Learn More]</code> on it.</p>
  
  <p>The reason that's happening is you have some CMS plugin/module that's injecting data on to every page.  You'll need to identify the plugin and change its settings.</p>
  
  <p><a href="https://i.sstatic.net/RDgiV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/RDgiV.png" alt="enter image description here"></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-18T21:16:40.830Z
Answers.LastActivityDate: 2018-07-18T21:16:40.830Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Body: <p>I have a Wordpress site (v4.2) and Civi 4.6.4 (although about to update). Every page on the public facing site generates a JS error (SyntaxError: Unexpected token '&lt;') referring to wp-login.php redirecting to the l10n-js file. I'm getting nowhere trying to understand a) why a public facing page is referencing wp-login.php in any event, let alone why a JS error is then getting generated.</p>
  
  <p>On contribution pages where the name and address profile uses the AJAX lookup for state/province, this is failing, leading to users not being able to successfully make a transaction. Not sure if the above JS error is the root cause of this, but two additional JS errors are appearing on these pages when trying to complete the profile:</p>
  
  <p>CRM.url called before initialization - referring to Common.js (line 1371)
  and then
  TypeError: undefined is not an object (evaluating 'tplURL[mode]') - referring to crm.ajax.js line 26</p>
  
  <p>Any insights most welcome.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-31T20:58:43.430Z
Comments.Text: The initial error seems to be caused because pages are attempting to load a script using  src="/wp-admin/admin.php?page=CiviCRM&q=civicrm/ajax/l10n-js/en_GB&r=NSPzH. This is going to work fine if the user is logged in, but as an anonymous user this presumably triggers the attempt to load wp-login.php, hence the script is seeing the opening '<' and the error gets generated. Changing the theme used stops the problem, so I'm looking at the theme as a next step.
Comments.UserDisplayName: Graham
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-31T23:17:22.413Z
Comments.Text: Does your theme contain a login page (one of it's own as) or something in  page.php that's invoking wp-admin, is it a configurable thing?
Comments.UserDisplayName: Lesley Evensen
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-18T21:10:30.770Z
Comments.Text: @Graham - I'm going to post a more detailed answer on how to troubleshoot - not because you need it, but because I intend to close some questions as duplicates of this.
Comments.UserDisplayName: Jon G - Megaphone Tech
Tags: <wordpress><ajax>
Title: "SyntaxError: Unexpected token" error on l10n-js files
ThreadText: # "SyntaxError: Unexpected token" error on l10n-js files
  
  (Asked by: username_0 on 2015-08-31)
  
  I have a Wordpress site (v4.2) and Civi 4.6.4 (although about to update). Every page on the public facing site generates a JS error (SyntaxError: Unexpected token '<') referring to wp-login.php redirecting to the l10n-js file. I'm getting nowhere trying to understand a) why a public facing page is referencing wp-login.php in any event, let alone why a JS error is then getting generated.
  
  On contribution pages where the name and address profile uses the AJAX lookup for state/province, this is failing, leading to users not being able to successfully make a transaction. Not sure if the above JS error is the root cause of this, but two additional JS errors are appearing on these pages when trying to complete the profile:
  
  CRM.url called before initialization - referring to Common.js (line 1371)
  and then
  TypeError: undefined is not an object (evaluating 'tplURL[mode]') - referring to crm.ajax.js line 26
  
  Any insights most welcome.
  
  **Tags:** wordpress, ajax
  
  > **Comments:**
  > **username_0**: The initial error seems to be caused because pages are attempting to load a script using  src="/wp-admin/admin.php?page=CiviCRM&q=civicrm/ajax/l10n-js/en_GB&r=NSPzH. This is going to work fine if the user is logged in, but as an anonymous user this presumably triggers the attempt to load wp-login.php, hence the script is seeing the opening '<' and the error gets generated. Changing the theme used stops the problem, so I'm looking at the theme as a next step.  
  > **username_1**: Does your theme contain a login page (one of it's own as) or something in  page.php that's invoking wp-admin, is it a configurable thing?  
  > **username_2**: @username_0 - I'm going to post a more detailed answer on how to troubleshoot - not because you need it, but because I intend to close some questions as duplicates of this.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-09-01. Score: 6
  
  Finally located the source of the problem. Every page on the site included a widget in the footer using an HTML snippet for a CiviCRM sign-up form. The HTML snippet, despite being the one generated by the profile, was incorrect, and included a reference to an admin URL for a script, which wouldn't be accessible to non-logged in site visitors. Removing it resolved the issue.
  
  > **Comments:**
  > **username_0**: Just to update further on this, the default HTML snippet for the profile  includes the line "var CRM = {"config":{"isFrontend":false}};" which to my mind looks incorrect. I would guess that this needs to set to 'true' for any public facing snippet?.  Also, at the end of a list of Javascript files I see the following: "<script type="text/javascript" src="/wp-admin/admin.php?page=CiviCRM&amp;q=civicrm/ajax/l10n-js/en_GB&amp;r=Lg7uq">" which makes me think that the snippet won't necessarily work for a non-logged in user, and looks to be the cause of my initial JS error noted in the question.  
  
  ---
  
  ### Answer by username_2 on 2018-07-18. Score: 2
  
  Generically: You have a Javascript error, so I would definitely consult the [Troubleshoot Javascript errors](https://forum.civicrm.org/index.php?topic=35850.0) post which describes additional steps to try.
  
  That said - I know what your problem is, and would like to give a step-by-step of how I worked it out.
  
  In your Javascript console (press F12 in your browser, then "Console" tab) you'll see a bunch of errors - but the first starts with "SyntaxError".
  A syntax error in JS will generally disable all the following JS on the page, which will lead to other JS not loading. So ignore everything after the SyntaxError, that will get fixed when you find the syntax error.
  
  Assuming your error is:
  
  ```
  SyntaxError: expected expression, got '<'[Learn More] en_US:1
  ...(more errors below)
  
  ```
  
  I can see the problem is on line 1 of the `en_US` file.
  
  So I open my browser's developer tools (F12). Then I go to the "Network" tab, filter by JS, and reload the page. I look for the en\_US file. I right-click and select "Open in New Tab" (see screenshot below).
  
  What you SHOULD see is a JavaScript file that tells CiviCRM how to load the correct translations for certain fields. What YOU will see is a first line with `<[Learn More]` on it.
  
  The reason that's happening is you have some CMS plugin/module that's injecting data on to every page. You'll need to identify the plugin and change its settings.
  
  [![enter image description here](https://i.sstatic.net/RDgiV.png)](https://i.sstatic.net/RDgiV.png)
  
  
  ---
  
  