SyntaxError: expected expression, got '>'

Are you seeing the following error message…

SyntaxError: expected expression, got '<'
<!DOCTYPE html>

…in Firefox’s dev tools but not in Chrome’s or Safari’s or another browser’s?

If so, it might be because you haven’t specified a URI in the src attribute of a <script> tag.

For example, the offending code in my codebase was:

<script src=""></script>

The fix is to make sure you specify a URI in your src. That is, to have no empty src attributes.

I thank Short.tips - SyntaxError: expected expression, got ‘<’ for the reference.

If you’d like to learn more, Nicholas C. Zakas goes into further detail about empty src attributes: Empty image src can destroy your site.

Twitter share ⤴