Skip to content

Commit

Permalink
Improve JS loading (#335)
Browse files Browse the repository at this point in the history
* Remove unused JS

* Only load JS when needed

* Compile Assets

* Inline theme event listener

---------

Co-authored-by: timacdonald <[email protected]>
  • Loading branch information
timacdonald and timacdonald authored Jul 10, 2024
1 parent 830500f commit 22f6319
Show file tree
Hide file tree
Showing 24 changed files with 99 additions and 9,671 deletions.
8 changes: 0 additions & 8 deletions .babelrc

This file was deleted.

33 changes: 0 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
"@docsearch/js": "^3.3.3",
"alpinejs": "^3.7.1",
"autoprefixer": "^10.4.14",
"babel-plugin-prismjs": "^2.0.1",
"clipboard": "^2.0.10",
"laravel-vite-plugin": "^0.7.6",
"postcss": "^8.4.21",
"postcss-import": "^14.0.0",
"prismjs": "^1.22.0",
"tailwindcss": "^3.3.0",
"vite": "^4.3.9"
}
Expand Down
1 change: 0 additions & 1 deletion public/build/assets/accessibility-1f45336a.js

This file was deleted.

29 changes: 0 additions & 29 deletions public/build/assets/app-2c9b9d45.js

This file was deleted.

1 change: 0 additions & 1 deletion public/build/assets/app-409e9bd3.css

This file was deleted.

1 change: 1 addition & 0 deletions public/build/assets/app-416e1687.css

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions public/build/assets/app-f72b41bb.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions public/build/assets/docs-59af3d22.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions public/build/assets/docs-80215298.js

This file was deleted.

20 changes: 4 additions & 16 deletions public/build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resources/css/app.css": {
"file": "assets/app-409e9bd3.css",
"file": "assets/app-416e1687.css",
"isEntry": true,
"src": "resources/css/app.css"
},
Expand Down Expand Up @@ -37,25 +37,13 @@
"src": "resources/images/vacation.svg"
},
"resources/js/app.js": {
"dynamicImports": [
"resources/js/docs.js",
"resources/js/components/accessibility.js"
],
"file": "assets/app-2c9b9d45.js",
"file": "assets/app-f72b41bb.js",
"isEntry": true,
"src": "resources/js/app.js"
},
"resources/js/components/accessibility.js": {
"file": "assets/accessibility-1f45336a.js",
"isDynamicEntry": true,
"src": "resources/js/components/accessibility.js"
},
"resources/js/docs.js": {
"file": "assets/docs-80215298.js",
"imports": [
"resources/js/app.js"
],
"isDynamicEntry": true,
"file": "assets/docs-59af3d22.js",
"isEntry": true,
"src": "resources/js/docs.js"
}
}
18 changes: 9 additions & 9 deletions resources/js/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Alpine from 'alpinejs';
import Focus from '@alpinejs/focus';

import './clipboard';
import './components/search';
import docsearch from '@docsearch/js';

import.meta.glob([
'../images/**',
Expand All @@ -13,10 +11,12 @@ window.Alpine = Alpine;
Alpine.plugin(Focus);
Alpine.start();

document.addEventListener('DOMContentLoaded', () => {
if (document.querySelector('#docsScreen')) {
import('./docs.js');
}

import('./components/accessibility');
docsearch({
container: '#docsearch',
appId: algolia_app_id,
apiKey: algolia_search_key,
indexName: 'laravel',
searchParameters: {
facetFilters: ['version:' + window.version],
},
});
Loading

0 comments on commit 22f6319

Please sign in to comment.