NO PRODUCT SETTINGS FOUND FOR:
examples

Gentle remainder that the product name comes from the `origin` first subfolder (after `/pms` ).

Script Module Test

This page demonstrates the new SCRIPT_MODULE fragment type, which allows embedding JavaScript modules directly in PM pages. The script will dynamically add content after the table below.

Sample Data Table

This table will be targeted by our script module:

Programming LanguageDifficulty LevelLearning TimeBest For
PythonBeginner3-6 monthsData Science, Web Development
JavaScriptIntermediate4-8 monthsWeb Development, Mobile Apps
JavaIntermediate6-12 monthsEnterprise Applications
C++Advanced12+ monthsSystem Programming, Games
RustAdvanced8-15 monthsSystem Programming, Performance

Interactive Script Module

The following YAML block contains a JavaScript module that will execute when the page loads:

Expected Behavior

When this page loads, you should see:

    1. Console Messages: Check browser console for execution logs
    2. Dynamic Content: A success panel should appear after the table
    3. Interactive Buttons: Buttons to highlight the table and add rows
    4. Visual Effects: Animations and styling changes when interacting

Technical Details

Fragment Type

  • Type: script_module_
  • YAML Key: fType: script_module_
  • Script Type: ES6 Module (type="module")
  • Content: Inline (content: |) or File Reference (src: path/to/file.js)

DOM Targeting

  • Uses data-f_type attributes to find fragments
  • Employs insertAdjacentElement() for precise placement
  • Leverages modern JavaScript features (arrow functions, template literals)

Security Notes

  • Content is processed through Jinja2's | safe filter
  • Runs in module context with natural scoping
  • Compatible with Content Security Policy

This demonstrates the power and flexibility of the new SCRIPT_MODULE fragment type for creating dynamic, interactive PM pages.


File Reference Example

The following example shows how to reference an external JavaScript file instead of embedding the script inline:

Enhanced Data Table

This table will be enhanced by an external script file:

FrameworkTypePerformanceLearning CurveBest For
ReactLibraryHighMediumSPAs, Component-based UIs
Vue.jsFrameworkHighEasyProgressive enhancement
AngularFrameworkHighSteepEnterprise applications
SvelteCompilerVery HighEasyPerformance-critical apps
Next.jsMeta-frameworkVery HighMediumFull-stack React apps

External Script Module

This script will: - Add sortable columns (click headers to sort) - Enable row highlighting and selection - Display table statistics - Provide export functionality - Allow adding sample rows

Comparison: Inline vs File Reference

ApproachUse CaseAdvantagesDisadvantages
Inline ContentSimple scripts, page-specific logicEasy to maintain, no external dependenciesCan make markdown files large
File ReferenceComplex scripts, reusable modulesBetter organization, reusability, syntax highlightingRequires external file management

Best Practices

    1. Use inline content for:
    2. Simple DOM manipulations
    3. Page-specific interactions
    4. Quick prototypes

    5. Use file references for:

    6. Complex functionality
    7. Reusable components
    8. Scripts shared across multiple pages
    9. When you need proper IDE support and debugging

This dual approach gives you maximum flexibility in how you organize and maintain your interactive PM content.

Maths.pm ne collecte aucune donnée.
Aucun cookie collecté, aucune ligne de log d'écrite, pas l'ombre d'une base de données distante - nihil omnino.
Toutes les exécutions de code se font localement. Nous expliquons notre démarche sur cette page.

Limites de confidentialité (impact de l'hébergeur)
Aspects technologiques
Chez Pointcarre.app, nous nous engageons en faveur des communs numériques.

Ressources pédagogiques
Logiciels Libres & Infrastructure 🇫🇷

Codes sources
Logo licence AGPLv3
Contenus
Logo licence Creative Commons

Maths.pm, par

pointcarre.app