# Javascript added to theme header returns $ is not defined

**URL:** https://meta.discourse.org/t/javascript-added-to-theme-header-returns-is-not-defined/371370
**Category:** Development
**Created:** [June 23, 2025, 5:26pm UTC](https://meta.discourse.org/t/javascript-added-to-theme-header-returns-is-not-defined/371370 "2025-06-23T17:26:36Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![opcourdis](https://avatars.discourse-cdn.com/v4/letter/o/45deac/32.png) [@opcourdis](https://meta.discourse.org/u/opcourdis)
#### Post date: [June 23, 2025, 5:26pm UTC](https://meta.discourse.org/t/javascript-added-to-theme-header-returns-is-not-defined/371370/1 "2025-06-23T17:26:36Z")

</div>

Hi,

In Admin \> Customize \> Themes \> in the header section I add the following but it returns  
Uncaught ReferenceError: $ is not defined

```plaintext
<script>
$(document).ready(function() {
$('.topic-list .topic-excerpt[href="/t/urltobechanged/8"]').attr('href', "/t/newurltoset/17 ");
});
</script>

```

If I add the following though, then it it works fine without error.

```plaintext
<script>
  console.log("Hello, Discourse!");
</script>

```

Mostly this $ is not defined error occurs because jQuery is not loaded, however shouldn’t the header scripts be by default executed after jQuery is loaded?h.

---

_[View the full topic](https://meta.discourse.org/t/javascript-added-to-theme-header-returns-is-not-defined/371370)._
