Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse template-section #2

Open
hanson-hschang opened this issue Jul 19, 2024 · 2 comments
Open

Reuse template-section #2

hanson-hschang opened this issue Jul 19, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@hanson-hschang
Copy link
Owner

Currently, all section pages, including about, resume, portfolio, blogs, notes, and contact, are first copy paste from template-section and modified through include-html.js. There should be a better way to reuse the template-section.

Similar ideas shown in each category of blogs, like science. It uses blog-post-loader.js to include necessary contents

@hanson-hschang hanson-hschang added enhancement New feature or request question Further information is requested labels Jul 19, 2024
@hanson-hschang hanson-hschang self-assigned this Jul 19, 2024
@hanson-hschang
Copy link
Owner Author

hanson-hschang commented Aug 2, 2024

We can dynamically load JavaScript file using following code snippet:

function loadScript(src) {
  var script = document.createElement('script');
  script.src = src;
  document.head.appendChild(script);
}

Scripts that are dynamically created and added to the document are async by default, which means they are not guaranteed to execute in the same order they are added.


JavaScript files can also be loaded with async and defer attributes.

<script async src="script.js"></script>
<script defer src="script.js"></script>

The defer attribute tells the browser to download the file, but wait until all of the other stuff is done before running the file. The async attribute tells the browser to download this file, but don’t stop downloading others while you do. The two can be used together.

So, the short answer is files are loaded in the order they appear in the HTML file.
The longer answer is … but it depends!


Screenshot 2024-08-02 at 3 52 29 PM

@hanson-hschang
Copy link
Owner Author

hanson-hschang commented Aug 16, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant