PageDriver means...

Feature rich function binding

Known as 'hooks' in other languages, bindings allow you to simply extend functions.

Source code

let demoCounterState = 0;
bind('EVENT', 'click', function demoBind() {
	demoCounterState++;
	populate('#demo-bind', { demoCounterState });
});

Painless DOM updates

populate() is all you need. From simple spans to complex multi-page forms, hydration is no longer a concern!

Use 100% plain HTML and a dash of PageDriver empowered JavaScript!

Demonstration

Source code - taphoverfocus to reveal explanation

/* Plain HTML... and a sprinkle of JS */
import { bind, EVENT, populate } from 'pd';

bind(EVENT, ['input','change', 'click'], function creature(event) { // Runs on 'input' and 'change' events, when the function name matches the <input> element name attribute.
	const newCreature = event.target.value.toLocaleLowerCase();
	populate('#demos', { creature:newCreature }); // Within '#demos' scope (this page), populate all 'creature' named inputs and elements with the 'pd_creature' class. Targeting the document body updates elements across your entire project!
	clowns.hidden = event.target.value.length < 30; // πŸ€”
});

'Context' based adventures

Context class demonstration

Because the Demo context class is enableddisabled, site elements with the -Demo CSS class don't appear, but elements with -Demo do. When you toggle the context, the reverse becomes true.

Perhaps an additional button will appear here once the reserved 'Debug' context is enabled? πŸ€”

Context classes allow the placement of site elements meant for different application states (ex. user roles or personas) within a single page, reducing site-wide content duplication (cardinality). This helps you maintain the “Don't Repeat Yourself” DRY coding principal.

Context classes are boolean CSS classes that show or hide content based on a matching class at the <body>. They are capitalized to differentiate from standard classes, and 'negated' versions are preceded by a hyphen - character.

Easy debugging …ENABLED! πŸ‘·β€β™€οΈ

Unless debug mode is enabled, PageDriver only outputs critical errors to the console. When errors occur in a production environment and debug mode is disabled, they can be passed to a pre-defined 3rd party monitoring service.

To see it in action, enable debug mode via the button above (or manually add a cookie named 'debug' and reload the site). We'll wait; and don't mind the clown, it leaves once debugging is enabled 🀑

You did it! The console now displays PageDriver information/insights, and a collapsed debug menu should be visible in top right of your viewport. This menu is opened via press or hotkey (in Chrome press alt+`). The bar's title is your project's current environment and favicon. Use the bar to quickly toggle between view contexts and open modals.

Feel free to explore its features at your own pace - but before moving on, try the visual 'Context' debugger.

Production vs development environments

PageDriver has two operational modes, 'development' and 'production'. 'Production' disables some developer-only framework functions for safety and enables additional auditing on others. 'Development' unlocks full debug capabilities, but disables some functionality by default (such as CSRF verification and caching) for practical reasons.

Server-side debugging

  • Only whitelisted clients are given remote debugging capabilities. The 'Environment' section of the debug menu shows this permission state.
  • Debug actions with security, stability, or privacy repercussions are logged for auditing.

Practical helper functionality

Our handy helpers keep you on track. For example, temporarily mutate HTML element attributes to add animation classes or disable buttons.

bind('EVENT', 'click', function demoTemporary(event) { temporary(event.target,'class','active',{ duration:1.5 }); });

No more page reloads

As of writing, PageDriver provides the ultimate SPA experience for both developers and users. You likely didn't realize it, but you loaded pretty much this ENTIRE site! Say goodbye to full page reloads in production environments.

Sending form data

Send a creature

Do more with less. Forms with well-formed (pun unintended) name attributes are all that is needed to call local APIs, no additional code needed. By default forms are sent asynchronously via POST and local requests have CSRF headers automatically appended.

PageDriver transforms your form name attributes into valid URLs. Here are some example transformations (assuming /api/v0 is your project's default API path):

  • name="user_authType"/api/v0/user/?authType
  • name="user_login_otpType"/api/v0/user/?login=otpType
  • name="many_underscores_much_wow"/api/v0/many/?underscores=much_wow

Don't worry, it's optional.

Adding the action HTML attribute with your remote URL as you would normally overrides the URL transformer. The rationale behind transformations was the enforcement of clean, grouped and logically named endpoints.

For complete control of the submission process you may replace PageDriver's default handler by adding your own global submit hook to pd.EVENT.

Getting remote data

Let's fetch some data from a remote API. PageDriver provides the pd.NET.xhr() function for this purpose.

😯 Uh oh...

A critical error has occurred preventing the site from loading. An error report has been automatically sent for investigation.

If this error is preventing you from completing an important action, please try again later.

Oops!

Search inoperable

We can't seem to find the requested page. If this error is preventing you from completing an important task, please contact us to resolve it.

We're sorry...

Something unexpected happened. If this error is preventing you from completing an important action, please contact us to resolve it.

500 Internal Server Error

Unauthorized access

You do not have the necessary permission to access this data.

401 Unauthorized

Oops!

We can't seem to find the requested resource. If this error is preventing you from completing an important action, please contact us to resolve it.

404 Not Found

Developer Preview

Welcome to the PageDriver 'Library v0' milestone preview. You've been invited at this critical juncture to provide early input and feedback about conventions and functionality. Intuitiveness is a primary project goal.

Please use the feedback tool zealously, for good or bad! Looking forward to reviewing your thoughts and opinions - Lorin

Please note

Getting help

Only community based support options are available at this time. Once officially launched, additional support options may become available.

Please fully review the official reference and guides before reaching out for assistance.

DEV 2025 Jan 08, 02:31am UTC πŸͺ²