Magento 2.1.9 – theme.js and responsive.js Not Loading in Custom Theme

cssmagento-2.1magento2theme

I have created a custom theme,

   Thomson/
    └── book
        ├── composer.json
        ├── media
        │   └── image.png
        ├── registration.php
        └── theme.xml

After that I choose my custom theme via admin, my frontend not load correctly.

I tried, static-content deploy, clear cache, and remove <m2>/var/* files

css are calling but theme.js and responsive.js is goes to 404.

Reference:

Error:

Frontend:

enter image description here

Suggest me, How to fix this..

Best Answer

There are two solutions

Solution 1 -

You need to define parent in your theme.xml file, so the that responsive.js and theme.js file will access from the parent theme

theme.xml ( app/design/frontend/Thomson/Book/theme.xml )

<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
   <title>Thomson Book</title> 
   <parent>Magento/blank</parent> <!-- the parent theme -->
   <media>
        <preview_image>media/preview.jpg</preview_image>
   </media>
</theme

Solution 2 -

You need to add both the files responsive.js and theme.js in your custom theme.

Thomson/
    └── book
        ├── composer.json
        ├── media
        │   └── image.png
        ├── registration.php
        └── theme.xml
        |-- web
             |--js
                 |--responsive.js
                 |--theme.js