Skip to content

Commit

Permalink
Optimisations (#1477)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmilton authored Jun 3, 2022
1 parent c762d65 commit 40ca6e3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async function makeHTML(name, stylePath, body = '') {
<meta charset=utf-8>
<title>New Tab</title>
<script src=${name}.js defer></script>
<style>${css}</style>
<style id=t>${css}</style>
${body}`;

await fs.writeFile(path.join(dir, 'dist', `${name}.html`), template);
Expand All @@ -154,7 +154,7 @@ await makeHTML(
'src/css/newtab.xcss',
// Theme loader as inline script for earliest possible execution start time +
// use localStorage for synchronous data retrieval to prevent FOUC
'<script id=t>let s=document.createElement("style");s.textContent=localStorage.t;t.after(s)</script>',
'<script>t.textContent+=localStorage.t</script>',
);
await makeHTML('settings', 'src/css/settings.xcss');

Expand Down
2 changes: 1 addition & 1 deletion manifest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = {
content_security_policy: [
"default-src 'none'",
// Hash of inline theme loader script embedded in the HTML
"script-src-elem 'self' 'sha256-tTEM8/3BDl1ZYg+4egLH8ztU+VEjQjhJbhCawNk+L2Q='",
"script-src-elem 'self' 'sha256-8N8wUVajC/wkiqNS1NQFp9Ec/Yk+LfiZ5zE4aZwH9E8='",
// App styles are embedded in the HTML for fastest load performance
"style-src-elem 'unsafe-inline'",
'img-src chrome://favicon',
Expand Down
2 changes: 1 addition & 1 deletion src/components/Search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const Search = (): SearchComponent => {
const sectionOrder = userSettings.o || DEFAULT_SECTION_ORDER;

sectionOrder.forEach((name) => {
section[name] = append(SearchResult(name, []), root);
section[name] = append(SearchResult(name), root);
});

const openTabs = section[DEFAULT_SECTION_ORDER[0]];
Expand Down
5 changes: 1 addition & 4 deletions src/components/SearchResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const DEFAULT_RESULTS_AMOUNT = 12; // chrome.topSites.get returns 12 items
const MORE_RESULTS_AMOUNT = 50;

const view = h(`
<div>
<div hidden>
<h2 #t></h2>
<div #l></div>
Expand All @@ -31,7 +31,6 @@ const view = h(`

export const SearchResult = <T extends LinkProps>(
sectionName: string,
data: T[],
): SearchResultComponent => {
const root = view.cloneNode(true) as SearchResultComponent;
const nodes = view.collect<RefNodes>(root);
Expand Down Expand Up @@ -78,7 +77,5 @@ export const SearchResult = <T extends LinkProps>(

nodes.m.__click = () => renderList(rawData, renderedLength + MORE_RESULTS_AMOUNT);

update(data);

return root;
};

0 comments on commit 40ca6e3

Please sign in to comment.