-
Notifications
You must be signed in to change notification settings - Fork 898
Description
Is your feature request related to a problem? Please describe.
We have a "classic" application. We render HTML on our backend and send it to the browser.
Currently we have to separately load the JS file and then apply it.
Describe the solution you'd like
If the theme files are available as JSON we have an extra option of just reading the JSON file on the server and applying it without a separate HTTP request. This improves time to interaction for classical applications.
Describe alternatives you've considered
Currently we do the classical approach. We could try to manually convert the themes to JSON during our build step.
Additional context
This JSON approach can even replace the classical approach; no more include needed.
Adapted from the docs here: (https://surveyjs.io/form-library/documentation/manage-default-themes-and-styles)
<!-- In classic script applications: -->
<head>
<!-- ... -->
<link href="https://unpkg.com/survey-core/survey-core.min.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/survey-core/survey.core.min.js"></script>
</head>const fetchTheme = fetch("https://unpkg.com/survey-core/themes/contrast-dark.min.json");
const surveyJson = { ... };
const survey = new Survey.Model(surveyJson);
const response = await fetchTheme;
if (!response.ok) {
console.warn("Failed to load theme")
} else {
const themeJson = await response.json();
survey.applyTheme(themeJson);
}You could even consider having an API like survey.applyThemeUrl(themeUrl). But this feature request is merely about exposing the themes as JSON.