# Javascript wrong in yarn start (while correct in build or build:production)

**URL:** https://discourse.roots.io/t/javascript-wrong-in-yarn-start-while-correct-in-build-or-build-production/20502
**Category:** sage
**Tags:** sage9, webpack
**Created:** 2021-04-02T10:02:44Z
**Posts:** 2

## Post 1 by @dangelion — 2021-04-02T10:02:44Z

Hi  
I’ve a clean install of **Sage 9.0.9** , I simply added this code:

**HTML in a page.blade.php tamplate**

```
<div class="container">
    <div class="h2-test">TEST TEST TEST</div>
  </div>
```

**CSS in main.scss**

```
.container {
  max-width: 80%;
  margin-left: auto;
  margin-right: auto;
  padding: 0;
  background: red;
}
```

**JS in common.js**

```
export default {
  init() {
    // JavaScript to be fired on all pages
  },
  finalize() {
    // JavaScript to be fired on all pages, after page specific JS is fired

    let slide_1 = document.querySelector('.h2-test');
    console.log(slide_1.offsetWidth);
  },
};
```

The console.log simply outputs the width of that element.  
While using `yarn start` it outputs a wrong value  
Instead with `yarn build` or `yarn build:production` the value is correct

Also, if I try to get a custom property from JS in yarn start it returns empty string while in build it works.

It seems an awful bug? How to solve?

---

## Post 2 by @strarsis — 2021-04-02T17:25:12Z

e class='quote' data-post="1" data-topic="20067"\>

 ![](https://discourse.roots.io/user_avatar/discourse.roots.io/strarsis/48/4543_2.png)
[Sage "9.1": Please test](https://discourse.roots.io/t/sage-9-1-please-test/20067) [sage](/c/sage/11)

> Note: Changed Sage 9.2 to 9.1 (as 9.0.10 is the current release in master). Updated Sage 9.x You can now try out the Sage PR branch for webpack 5 and updated dependencies. The sage-installer which is used by Sage 9.x for adding framework support was also updated to add the right configuration and styles. Bootstrap 5 (Beta2) has been added for selection. Tailwind 2 is used now. Trying it out now! To prevent siloing of existing working forks of Sage 9 + (insert framework), please try this set…
