# SA5 Core

For some time we've been developing the central engine shared by all libraries. It has a few key roles;

* Centralized debugging and debug state management&#x20;
* Event handler registration
* Configuration handler registration
* Global vars

Eventually, we'll be expanding it to add a few other key capabilities;

* Remote monitoring
* Smart-loading

### What is Smart Loading?

Smart Loading is a means to conveniently detect and load SA5's many libraries dynamically, depending on the configurations found in the webpage-

* Script config blocks
* SA5 custom attributes

Features;

* Drop in one references, and all libs are automatically accessible ( same version as core )
* Detection of unknown attributes, or misspelled attributes, or obsolete
* Controlled order of execution, internal dependencies&#x20;

## Loading Technique

Pre-DOM load

e.g. for inline script changes like SEO work

Post-DOM load

Most work is done here&#x20;

```javascript
if (document.readyState !== 'loading') {
    console.log('document is already ready, just execute code here');
    myInitCode();
} else {
    document.addEventListener('DOMContentLoaded', function () {
        console.log('document was not ready, place code here');
        myInitCode();
    });
}

function myInitCode() {}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://attr.sygnal.com/overview/sa5-core.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
