If you are only using the opto because the input voltage is higher, an opto is overkill. If you need an opto due to safety (unlikely with 24V) or noise, then just an opto is insufficient; You would need isolated or separate supplies and grounds too and isolation for all other signals crossing that power supply boundary.
simulate this circuitsimulate this circuit – Schematic created using CircuitLab
The main difference is the Zener clamps the voltage even when the 3.3V is unpowered which could be important if the pulse source can be powered while the 3.3V is unpowered. The Zener is slower and produces more heat in the diode, though heat is negligible due to the current limiting of the resistor.
The rail clamp diode can be faster if properly chosen (like a Schottky diode) with more flexible clamping voltage but needs 3.3V power.