Skip to content

Instantly share code, notes, and snippets.

View hansamlin's full-sized avatar
🎯
Focusing

Sam Lin hansamlin

🎯
Focusing
View GitHub Profile
@hansamlin
hansamlin / dom_performance_reflow_repaint.md
Created July 23, 2024 08:38 — forked from faressoft/dom_performance_reflow_repaint.md
DOM Performance (Reflow & Repaint) (Summary)

DOM Performance

Rendering

  • How the browser renders the document
    • Receives the data (bytes) from the server.
    • Parses and converts into tokens (<, TagName, Attribute, AttributeValue, >).
    • Turns tokens into nodes.
    • Turns nodes into the DOM tree.
  • Builds CSSOM tree from the css rules.
@hansamlin
hansamlin / Messages.js
Created September 13, 2021 08:49 — forked from Gpx/Messages.js
Check if user is logged in Express otherwise redirect to /login
// Set an error message and redirect
var redirectWithMessage = function (message, url, req, res) {
req.session.messages = message;
res.redirect(url);
};
// Return 'messages' value or null instead
var getMessages = function (req) {
var messages = req.session.messages || null;
delete req.session.messages;