Skip to Main Content
Gutenberg Handbook

Resources for BU WordPress designers and developers

  • Creating a Block Using a Template
  • Fundamentals
    • BU Tools
    • WP Core
  • Best Practices
    • BU Child Starter
    • Organizing Block Code
    • Dynamic vs Static
    • Do I need a Custom Block?
    • Approach to Foundational Block Styling
    • Block Patterns
  • Tutorials
    • Basic Dynamic Block
    • Basic Static Block
    • Inspector Controls
    • Setting up a child theme
    • BU Plugin Starter
    • Using Create-Block Template
    • Creating a Component
    • Testing the Block
    • Deprecating a Block
  • Blog
    • Updates
    • Explainers
  • Resources
    • Training
    • Documentation
    • Repositories
    • Glossary
Search

view.js / viewScript (Frontend JS)

Block type frontend scripts definition. They will be enqueued only when viewing the content on the front of the site.

@todo embed https://github.com/bu-ist/labs-theme-blocks/blob/sandbox/src/blocks/theme/view.js

If your block does not need JS, view.js can be deleted and viewScript removed from block.json.

@todo embed https://github.com/bu-ist/labs-theme-blocks/blob/sandbox/src/blocks/theme/block.json line 14

[alert icon] All coding must follow BU and WordPress JavaScript Coding Standards.

See WordPress Developer Resources: View script

Related to view.js / viewScript (Frontend JS)

Fundamentals

  • BU Tools
  • WP Core
    • Block Architecture
      • viewScript (Frontend JS)
      • editorStyle (Admin Styling)
      • viewStyle (Frontend Styling)
      • render (Frontend Template)
      • block.json
      • Attributes
    • Anatomy of a Block
    • Importing Components
    • useBlockProps
    • Inner Blocks
    • Block Icons, Naming, & Categories
    • Block Styles
    • Block Patterns
    • Block Variations
    • Block API
    • Block Wrapper Props: useBlockProps
    • Inner Blocks
    • Components Reference
    • Reusable Blocks
Boston University
  • Boston University
  • Search
  • Directory
  • BU Today
© 2025 Boston University. All rights reserved. www.bu.edu